package com.example.goukakuproject;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class GKQuizscreen extends Activity {

	int bai = 0, trinhDo = 0;
	int tuBai = 0;
	int denBai = 0;
	int soCauHoi = 0;
	int loai = 0; //loai 1: Tu Vung, loai 2: Chu Han
	int loai2 = 0; // 1: Nhat Viet va Kanji Nghia. 2 nguoc lai
	int cauHoiThu = 1;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_gkquizscreen);
		Intent callerIntent=getIntent();
		Bundle packageFromCaller = callerIntent.getBundleExtra("QuizTabIntent");		
		trinhDo = packageFromCaller.getInt("trinhdo");
		tuBai = packageFromCaller.getInt("tubai");
		denBai = packageFromCaller.getInt("denbai");
		soCauHoi = packageFromCaller.getInt("socauhoi");
		loai = packageFromCaller.getInt("loai");
		loai2 = packageFromCaller.getInt("loai2");
		final TextView tvCauHoi = (TextView) findViewById(R.id.tvQuizQuesNo);
		final TextView tvWord = (TextView) findViewById(R.id.tvWord);
		final TextView tvAnswer1 = (TextView) findViewById(R.id.tvQuizAnswer1);
		final TextView tvAnswer2 = (TextView) findViewById(R.id.tvQuizAnswer2);
		final TextView tvAnswer3 = (TextView) findViewById(R.id.tvQuizAnswer3);
		final TextView tvAnswer4 = (TextView) findViewById(R.id.tvQuizAnswer4);
		if (loai == 1){
			if (loai2 == 1) tvWord.setText("Tu vung. Nhat - Viet");
			else tvWord.setText("Tu vung. Viet - Nhat");
		}
		else {
			if (loai2 == 1) tvWord.setText("Chu Han. Chu Han - Nghia");
			else tvWord.setText("Chu Han. Nghia - Chu Han");
		}
		tvCauHoi.setText("Cau hoi 1/" + soCauHoi);
		tvAnswer1.setText("Dap an 1 cau hoi 1");
		tvAnswer2.setText("Dap an 2 cau hoi 1");
		tvAnswer3.setText("Dap an 3 cau hoi 1");
		tvAnswer4.setText("Dap an 4 cau hoi 1");
		
		Button btnDanhSach = (Button) findViewById(R.id.BackToQuizSetting);
		Button btnPre = (Button) findViewById(R.id.btnQuizScreenPre);
		Button btnNext = (Button) findViewById(R.id.btnQuizScreenNext);
		btnDanhSach.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				finish();				
			}
		});	
		btnPre.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				if (cauHoiThu == 1) return;
				cauHoiThu = cauHoiThu - 1;				
				tvCauHoi.setText("Cau hoi " + cauHoiThu + "/" + soCauHoi);
				tvAnswer1.setText("Dap an 1 cau hoi " + cauHoiThu);
				tvAnswer2.setText("Dap an 2 cau hoi " + cauHoiThu);
				tvAnswer3.setText("Dap an 3 cau hoi "+ cauHoiThu);
				tvAnswer4.setText("Dap an 4 cau hoi "+ cauHoiThu);
			}
		});
		btnNext.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				if (cauHoiThu == soCauHoi) return;
				cauHoiThu = cauHoiThu + 1;				
				tvCauHoi.setText("Cau hoi " + cauHoiThu + "/" + soCauHoi);
				tvAnswer1.setText("Dap an 1 cau hoi " + cauHoiThu);
				tvAnswer2.setText("Dap an 2 cau hoi " + cauHoiThu);
				tvAnswer3.setText("Dap an 3 cau hoi "+ cauHoiThu);
				tvAnswer4.setText("Dap an 4 cau hoi "+ cauHoiThu);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.gkquizscreen, menu);
		return true;
	}

}
